<template>
  <div class="nav-bar" :class="{ is_fixed: isFixed }">
    <div class="container">
      <div class="pro-title">{{name}}</div>
      <div class="pro-param">
        <a href="javascript:;">概述</a><span>|</span>
        <a href="javascript:;">参数</a><span>|</span>
        <a href="javascript:;">用户评价</a>
        <slot name="buy"></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "nav-bar",
  props: ["name"],
  data() {
    return {
      isFixed: false,
    };
  },
  mounted() {
    window.addEventListener("scroll", this.initHeight);
  },
  methods: {
    initHeight() {
      let scrollTop = window.pageYOffset;
      this.isFixed = scrollTop > 152 ? true : false;
    },
  },
};
</script>

<style lang="scss">
@import "./../assets/scss/config.scss";
@import "./../assets/scss/mixin.scss";

.nav-bar {
  height: 70px;
  line-height: 70px;
  border-top: 1px solid $colorH;
  background-color: $colorG;
  z-index: 10;
  .container {
    @include flex();
    .pro-title {
      color: $colorB;
      font-size: $fontH;
      font-weight: bold;
    }
    .pro-param {
      a {
        font-size: $fontJ;
        color: $colorC;
        &:last-of-type {
          margin-right: 11px;
        }
      }
      span {
        margin: 0 10px;
      }
    }
  }
  &.is_fixed {
    position: fixed;
    top: 0;
    width: 100%;
    box-shadow: 0 3px 5px #ccc;
  }
}
</style>